package com.anlu.pattern.create.factory.simple;

import com.anlu.pattern.common.entity.Fruit;
import com.anlu.pattern.common.entity.fruit.Apple;
import com.anlu.pattern.common.entity.fruit.Banana;
import com.anlu.pattern.common.entity.fruit.Orange;

/**
 * 简单工厂模式
 * @author anlu
 * @create 2019/11/21
 **/

public class StaticFactory {
    // 苹果
    public static final int TYPE_APPLE = 1;
    //桔子
    public static final int TYPE_ORANGE = 2;
    //香蕉
    public static final int TYPE_BANANA = 3;

    public static Fruit getFruit(int type){
        if(TYPE_APPLE == type){
            return new Apple();
        }else  if(TYPE_ORANGE==type){
            return new Orange("Peter",80);
        }else if(TYPE_BANANA==type){
            return new Banana();
        }
        return null;
    }


    public static Fruit getFruitApple(){
        return new Apple();
    }

    public static Fruit getFruitOrange(){
        return new Orange("Peter",80);
    }

    public static Fruit getFruitBanana(){
        return new Banana();
    }


}
